package org.example.remote.service;

import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.example.vo.Result;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@FeignClient(name = "upload",url = "http://127.0.0.1:6000")
public interface IUploadRemoteService {
    /*
     * 从静态资源文件夹中获取用户照片，需要验证用户token的id与保存的id一致
     * 1 、营业执照 2、身份证照片
     */
    @GetMapping("/userFile/{userID}/{type}")
    feign.Response getUserFile(@PathVariable String type, @PathVariable String userID, HttpServletResponse response);

    @PostMapping("/userFile/{userID}/{type}")
    /*
     * 将用户照片保存到服务器绝对路径中，不作静态资源映射以保证数据安全
     */
    Result<?> uploadUserFile(@PathVariable String userID, @PathVariable String type, @RequestParam("file") MultipartFile img);

    /*
     * 当审核系统审批完秒杀业务后，库存后台调用此接口上面对应的静态界面
     */
    @PostMapping(value = "/secKill/{GoodsId}",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String saveSecKillHtml(@RequestPart("file") MultipartFile html, @PathVariable String GoodsId);



}
